import { getChannelList, updateSaasCompany } from '@/api/company'

import { message } from 'ant-design-vue'
import { Component, Emit, Prop, Watch } from 'vue-facing-decorator'
import Render from '@/render/Render'
import renderModal, {
    getModelValue,
    initModelValue,
    type FormModalDto
} from '@/components/modal/Modal'
import toNative from '@/utils/toNative'
import { getReceiptData } from '@/utils/util'
import type { CompanyInfoDto } from '@/api/company/types'
import type { LongInsuranceCaseListDto,ReportCaseResultDto } from '@/api/insurance/period/types'
import { getKeyToEnum, InsuranceIndemnifyEnum } from '@/const/enum'
import { setPeriodInsurClaim,setDailyInsurClaimOne,setDailyInsurClaimTwo } from '@/api/insurance/period'
@Component
export class EditAgent extends Render {
    @Prop({ default: false }) show!: boolean
    @Prop() basicInfo!: LongInsuranceCaseListDto<ReportCaseResultDto>
    @Emit('update:show')
    showChange(val: boolean) {return val}

    @Emit('refresh')
    handleRefresh() {}

    @Watch('show', { immediate: true })
    async handleWatchShow() {
        this.formConfig.show = this.show
        if (this.show) {
            this.basicInfo.isVisible = 1
            initModelValue(this.formConfig, this.basicInfo)
        }
    }

    formConfig = this.initFormConfig() as FormModalDto

    initFormConfig() {
        return {
            title: '新增方案',
            theme: 'dark',
            show: false,
            items: {
                reportStatus: {
                    name: '系统账户',
                    element: 'input',
                    required:true
                },
                reportRemark: {
                    name: '系统名称',
                    element: 'input',
                    required:true
                },
                productId: {
                    name: '开通产品',
                    element: 'select',
                },
                examine: {
                    name: '工种审核',
                    element: 'radioGroup',
                    options: [
                        {
                            label: '开启',
                            value: 1
                        },
                        {
                            label: '关闭',
                            value: 0
                        }
                    ]
                }
            },
            complete: async () => {
                const data = getModelValue(this.formConfig)
                message.success('操作成功')
                this.handleRefresh()
                this.formConfig.show = false
                this.showChange(false)
            },
            cancel: () => {
                this.formConfig.show = false
                this.showChange(false)
            }
        } as FormModalDto
    }

    render() {
        return <div>{renderModal(this.formConfig)}</div>
    }
}

export default toNative<{  }, { refresh: () => void }>(EditAgent)
